package com.atguigu.juc.t9;


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class T1 {
    public static void main(String[] args) {
        //创建线程池的方式一:原始方法自己创建
//        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1,1,1,null,null);


        //创建线程池的方式二：调用线程池工具，创建
        ExecutorService executorService = Executors.newCachedThreadPool();
        ExecutorService executorService1 = Executors.newSingleThreadExecutor();
        ExecutorService executorService2 = Executors.newFixedThreadPool(1);

        executorService.submit(()->{
            System.out.println(Thread.currentThread().getName() + "线程池开始工作");
        });
        executorService.shutdown();
        executorService1.shutdown();
        executorService2.shutdown();
    }
}
